Here are some functions we’ll apply to each species. I’ll then fit mixed models with all of them using
with a gaussian error. Note, it’s count, so, I could use Poisson, but, that needs to be way more tuned to each model - this should be fine for a first cut?
Here’s how we’ll do it:
tseries_plot <- function(data){
ggplot(data,
aes(y = Count, x = Year,
color = Transect)) +
stat_summary(fun.data = mean_se) +
stat_summary(fun.data = mean_se, geom = "line") +
labs(color = "Transect",
y = "Count per sq m ± SE", x = "Year")
}
tseries_fun <- function(data){
glmmTMB(Count ~ Year + (1|Transect),
data = data,
family = gaussian)
}
generate_output <- function(data){
cat(paste0("## ", data$Organism[1], " ", data$Organism[1], " \n<br>"))
tseries_plot(data) %>% print()
# tseries_fun(adf) %>%
# car::Anova(test.statistic = "Chisq") %>%
# tidy() %>%
# knitr::kable("html", digits = 3) %>%
# kableExtra::kable_styling() %>%
# print
#
cat("\n\n")
}
Now let’s purrr::walk() through the whole shebang.
walk(split(data, data$Organism), generate_output)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?